//
//  CreatAddressLastCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/27.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "CreatAddressLastCell.h"

@interface CreatAddressLastCell ()
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (weak, nonatomic) IBOutlet UILabel *placehoderLabel;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomMargin;

@end

@implementation CreatAddressLastCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.leftLabel.font = MYFONT(15);
    
    self.placehoderLabel.font = MYFONT(15);
    
    self.bottomMargin.constant = 7;
    
    self.placehoderLabel.textColor = placeholderColor;
    
    self.placehoderLabel.text = @"街道,楼牌号等";
    
    self.textView.scrollEnabled = NO;
    
    self.textView.font = MYFONT(15);
    
    self.placehoderLabel.font = MYFONT(15);
    
    self.textView.autocapitalizationType = UITextAutocapitalizationTypeNone;
//    [self.textView setAutocapitalizationType:UITextAutocapitalizationTypeNone];
    // Initialization code
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textChange) name:UITextViewTextDidChangeNotification object:self.textView];
    
}

- (void)setModel:(AddressInfoModel *)model{
    _model = model;
    
    if (_model.address.length > 0) {
        
        self.textView.text = _model.address;
        
        [self textChange];
    }
    
}



- (void)textChange{
    
    self.model.address = self.textView.text;

    self.placehoderLabel.hidden = self.textView.hasText;
    
    [self.tableView beginUpdates];
    
    [self.tableView endUpdates];
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
